#include "walle.hpp"

Walle::Walle(Vision* vision, Robot* robot, double fireOnAccuracy)
{
	this->vision = vision;
	this->robot = robot;
	this->fireOnAccuracy = fireOnAccuracy;
}

cv::Rect Walle::guide(cv::Mat& frame)
{
	vision->capture(frame);
	if (vision->spot()) {
		//if aimed, fire, else keep spotting
		if (vision->ds < fireOnAccuracy) {
			robot->cmd(vision->dx, vision->dy, vision->dz, 0xff);
		} else {
			robot->cmd(vision->dx, vision->dy, vision->dz, 0x00);
		}
	}
	// initiatively searching
	else {

	}
	return vision->target;
}